<?php $i = 0; ?>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
    <div class="header clearfix">
<!--        <nav>-->
<!--            <ul class="nav nav-pills pull-right">-->
<!--                <li role="presentation" class="active"><a href="--><?php //echo Yii::app()->baseUrl; ?><!--/admin/server"">列表</a></li>-->
<!--                <li role="presentation"><a href="--><?php //echo Yii::app()->baseUrl; ?><!--/admin/serverChange">新增</a></li>-->
<!--            </ul>-->
<!--        </nav>-->
        <h3 class="text-muted">列表</h3>
    </div>

    <div class="table-responsive">
        <table class="table table-striped">
            <thead>
            <tr>
                <th>#</th>
                <th>姓名</th>
                <th>内容</th>
                <th>电话</th>
                <th>邮箱</th>
                <th>时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <?php if(is_array($data)){
                foreach($data as $k => $v){
                    $i++
                    ?>

                    <tr>
                        <td><?php echo $i ?></td>
                        <td><?php echo $v['name'] ?></td>
                        <td><?php echo $v['body'] ?></td>
                        <td><?php echo $v['phone'] ?></td>
                        <td><?php echo $v['email'] ?></td>
                        <td><?php echo date("Y-m-d H:i:s",$v['time']) ?></td>
                        <td>
                            <a href="javascript:void(0)" onclick="del_show('<?php echo $v['id'] ?>')" >删除</a>
                        </td>
                    </tr>
                <?php
                }
            }?>
            <?php if($i == 0){ ?>
                <tr>
                    <td colspan="7">暂无数据</td>
                </tr>
            <?php } ?>
            </tbody>
        </table>
    </div>
    <?php echo $page_list ?>
</div>


<!-- Modal -->
<div class="modal fade" id="msgBox" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">提示</h4>
            </div>
            <div class="modal-body">
                确定删除吗?
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="del()">确认</button>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var sumbit_type= 1,i=0;
    var del_id=0;
    function del_show(id){
        del_id=id;
        $('#msgBox').modal('show')
    }
    function del(){
        if(sumbit_type==0){alert('正在执行..');return false;}
        $.post("<?php echo Yii::app()->baseUrl; ?>/admin/messageDel",{ id:del_id},function(data){
            if(data.length>0 && data=='ok'){
                Refresh();
            }else{
                i++;
                $('#msgBox .modal-body').html('删除失败'+i+'次,再次删除?')
                $('#msgBox').modal('show')
            }
        });
    }
    //刷新
    function Refresh() {
        location.reload();
    }
</script>
